package com.xidian.zhiancloud.controller.myyb;

import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.SysMenuRight;
import com.xidian.zhiancloud.service.myyb.ISysMenuRightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 角色菜单赋权限
 */
@RestController
@RequestMapping(value = "/sys/menuRitht")
public class SysMenuRightController {

    @Autowired
    private ISysMenuRightService sysMenuRightService;

    /**
     * 查询列表
     * @param sysMenuRight
     * @return
     */
    @RequestMapping("/getList")
    public ResultDTO<List<SysMenuRight>> getList(SysMenuRight sysMenuRight){
        return ResultDTO.successOf(sysMenuRightService.getListByMenuRight(sysMenuRight),
                GeneralResponseEnums.SUCCESS);
    }


    /**
     * 添加角色菜单赋权限
     * @param sysMenuRight 角色菜单赋权限
     * @return 返回 ResultDTO 对象
     */
    @PostMapping("/saveSysMenuRight")
    public ResultDTO<Boolean> saveSysMenuRight(SysMenuRight sysMenuRight) {
        sysMenuRightService.save(sysMenuRight);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

}
